package com.easy.sso.resolver;

import com.easy.common.util.Result;
import com.easy.common.util.Tools;
import com.easy.sso.exception.JwtException;
import com.easy.sso.exception.LoginException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-04-19 19:44
 **/
@ControllerAdvice
public class ExceptionResolver {
    //处理登录异常
    @ExceptionHandler(value = LoginException.class)
    @ResponseBody
    public String loginExceptionResolver(LoginException ex) {
        return Tools.object2Json(Result.error(ex.getException()));
    }

    //处理jwt异常
    @ExceptionHandler(value = JwtException.class)
    @ResponseBody
    public String jwtExceptionResolver(JwtException ex) {
        return Tools.object2Json(Result.error(ex.getException()));
    }
}
